<!-- 我的投递记录 -->
<template>
    <div>
        <!-- 头部 -->
        <reception-header/>
        
        <div class="main-deliver">
            <el-empty 
                :image-size="300" 
                description="您还没有投递过任何岗位，快去投递吧！"
                v-if="notDeliverRecord"
            >
            </el-empty>
            <div class="deliver-main" v-if="!notDeliverRecord">
                <div class="item-deliver">
                    <div v-for="(item,index) in deliverList" :key="index">
                        <el-row>
                            <el-col :span="18">
                                <span 
                                    class="position"
                                    @click="toRecruitDetail(item.recruitmentInfoAid,item.companyAid)"
                                >
                                    {{item.positionName}}
                                </span>
                            </el-col>
                            <el-col :span="6"><span class="date">{{item.deliverTime}} 申请</span></el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="18">
                                <span class="second-hang">{{item.recruitAddress}}&emsp;|&emsp;</span>
                                <span class="second-hang">{{item.education === null ? '学历无要求' : item.education}}</span>
                            </el-col>
                            <el-col :span="6">
                                <span 
                                    class="company" 
                                    @click="toCompanyHandle(item.companyAccount)"
                                >
                                    {{item.companyName}}
                                </span></el-col>
                        </el-row> 
                        <el-divider></el-divider>                
                    </div>                   
                </div>
            </div>
        </div>

        <!-- 底部 -->
        <the-footer/>
    </div>
</template>

<script>
import ReceptionHeader from '../../components/ReceptionHeader.vue'
import TheFooter from '../../components/The-Footer.vue'
import { checkLoginUserIsHaveDeliverRecord,queryLoginUserDeliverRecord } from "../../api/personalApi/index";
import { getStore } from '../../storage/storage'
export default {
    components: { ReceptionHeader,TheFooter },
    data () {
        return {
            notDeliverRecord: true, // 是否有投递记录
            positionName: '', // 岗位名称
            deliverTime: '', // 投递时间：2022-2-13
            recruitAddress:'', // 招聘地点
            education: '', // 学历要求
            companyName: '', // 公司名称
            deliverList: [], // 投递记录list
        }
    },
    created(){
        // 判断当前登陆的用户是否有投递记录
        this.checkLoginUserIsHaveDeliverRecordFunc();

        // 查询当前登陆用户的投递记录
        this.queryLoginUserDeliverRecordFunc();

    },
    methods:{
        // 判断当前登陆的用户是否有投递记录
        checkLoginUserIsHaveDeliverRecordFunc(){
            const params = {
                account: getStore("account"),
            }
            checkLoginUserIsHaveDeliverRecord(params).then(res=>{
                if (res.data.data) {
                    this.notDeliverRecord = false;
                }else{
                    this.notDeliverRecord = true;
                }
            })
        },

        // 查询当前登陆用户的投递记录
        queryLoginUserDeliverRecordFunc(){
            const params = {
                account: getStore("account"),
            }
            queryLoginUserDeliverRecord(params).then(res=>{
                console.log(res);
                this.deliverList = res.data.data.list;
            })
        },

        // 去公司页面
        toCompanyHandle(account){
            this.$router.push({
                path: '/reception/companyAllRecruitmentInfo',
                query: {
                    name: account,
                }
            });
        },

        // 去招聘详情页面
        toRecruitDetail(recruitmentInfoAid,companyAid){
            this.$router.push({
                path: "/reception/recruitInfoDetail",
                query: {
                    companyAid: companyAid,
                    recruitmentInfoAid: recruitmentInfoAid,
                }
            });
        },

    }
}
</script>

<style scoped>
@import "../../assets/css/reception/myDeliverRecord.css";
</style>
